<template lang="">
    <div>
        {{ text }}
    </div>
    <div>
        <div>{{ data1 }}</div>
        <div>{{ data2 }}</div>
    </div>
    <button @click="setText">设置1</button>
    <button @click="setText2">设置2</button>
</template>
<script>
export default {
    data() {
        return {
            text: '',
            data1: null,
            data2: null,
        }
    },
    methods: {
        setText() {
            // this.text = '1'
            // setTimeout(() => {
            //     this.text = '2'
            // }, 2000)
            // console.log(6666666, this)
            const self = this
            setTimeout(function() {
                console.log(99999999)
                self.text = '2'
            }, 1000)
            console.log(123123123)
        },
        setText2() {
            const pro = new Promise((resolv, reject)=> {
                setTimeout(() => {
                    console.log(1111111)
                    this.data1 = 2
                    resolv(this.data1)
                }, 2000)
            })
            // console.log(pro, 555555)
            pro.then((num) => {
                console.log(num, 321)
            }).catch(() => {
                
            }).finally(() => {
                console.log('douzhixingle1')
            })
            const pro1 = new Promise((resolv, reject)=> {
                setTimeout(() => {
                    console.log(1111111)
                    this.data2 = 2
                    resolv(this.data2)
                }, 2000)
            })
            Promise.all([pro, pro1]).then(res => {}).catch()
        }
    }
}
</script>
<style lang="">
    
</style>